home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / misc / volume12 / psf2 / part03 < prev    next >
Encoding:
Text File  |  1990-05-19  |  43.0 KB  |  1,635 lines

  1. Newsgroups: comp.sources.misc
  2. From: tony@ajfcal.UUCP (Tony Field)
  3. subject: v12i106: psf2.0 source 3/6
  4. Sender: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)
  5.  
  6. Posting-number: Volume 12, Issue 106
  7. Submitted-by: tony@ajfcal.UUCP (Tony Field)
  8. Archive-name: psf2/part03
  9.  
  10. psf2.0 source 3/6
  11. =================
  12. #! /bin/sh
  13. # This is a shell archive.  Remove anything before this line, then unpack
  14. # it by saving it into a file and typing "sh file".  To overwrite existing
  15. # files, type "sh file -c".  You can also feed this as standard input via
  16. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  17. # will see the following message at the end:
  18. #        "End of archive 3 (of 6)."
  19. # Contents:  Install.xenix Readme.Install Readme.Xenix pmf.c pnf.c
  20. #   selectdef.c
  21. # Wrapped by ajf@trifid on Tue May 15 01:10:45 1990
  22. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  23. if test -f 'Install.xenix' -a "${1}" != "-c" ; then 
  24.   echo shar: Will not clobber existing file \"'Install.xenix'\"
  25. else
  26. echo shar: Extracting \"'Install.xenix'\" \(6508 characters\)
  27. sed "s/^X//" >'Install.xenix' <<'END_OF_FILE'
  28. X:
  29. X#    Install psf filters on Xenix 2.*   (install.xenix)
  30. X#
  31. X#    note:      this script records configuration parameters in
  32. X#        various ".cfg" files in the current directory.
  33. X#        it also expects some .cfg files to be created
  34. X#        by "selectdef".
  35. X
  36. XPATH=.:/bin:/usr/bin:/etc
  37. X
  38. XINSTALLPOINT="/tmp/psf"
  39. X
  40. X# sense if we are running from "install" or from a normal directory
  41. X# If from "install" then  $0 == "init.psf".  the normal script file
  42. X# name is "installpsf".
  43. X
  44. Xcase $0 in
  45. X  *Install.xenix)
  46. X      ;;
  47. X  *)    cd $INSTALLPOINT
  48. X      ;;
  49. Xesac
  50. X
  51. XDEFDIR="/usr/spool/lp/model/psfprint.def"
  52. XBINDIR="/usr/local/bin"
  53. XSPOOLDIR="/usr/spool/lp"
  54. X
  55. XINTERFACE="$SPOOLDIR/interface"
  56. XMODEL="$SPOOLDIR/model"
  57. XDEFFILES="defs/*.def"
  58. XPAGESIZE="undefined"
  59. XPNAME="undefined"
  60. XBINARIES="psf pnf pmf psd psbanner psdetect"
  61. XMANS="psf.1 pnf.1 pmf.1 psd.1 psmbox.1 psman.1 psnroff.1"
  62. XSCRIPTS="psmbox psman psmandouble psnroff"
  63. XMANCHAP="LOCAL"
  64. X
  65. X
  66. X#    get existing psf installation parameters
  67. X
  68. Xif test -f Pmanchap.cfg
  69. Xthen
  70. X    MANCHAP=`cat Pmanchap.cfg`
  71. Xfi
  72. X
  73. Xif test -f Pbindir.cfg
  74. Xthen
  75. X    BINDIR=`cat Pbindir.cfg`
  76. Xfi
  77. X
  78. X# Define return values
  79. X
  80. X: ${OK=0} ${FAIL=1} ${STOP=10} ${HALT=11}
  81. X
  82. X    
  83. X# Print an error message
  84. Xerror() {
  85. X    echo "\nError: $*" >&2
  86. X    return 1
  87. X}
  88. X
  89. X# Prompt with mesg, return non-zero on q
  90. Xprompt() {
  91. X    while    echo "\n${mesg}or enter q to $quit: \c" >&2
  92. X    do    read cmd
  93. X        case $cmd in
  94. X        +x|-x)    set $cmd                    ;;
  95. X        Q|q)    return 1                    ;;
  96. X        !*)    eval `expr "$cmd" : "!\(.*\)"`            ;;
  97. X        "")    # If there is an argument use it as the default
  98. X            # else loop until 'cmd' is set
  99. X            [ "$1" ] && { 
  100. X                cmd=$1
  101. X                return 0
  102. X            }
  103. X            : continue
  104. X            ;;
  105. X        *)    return 0                    ;;
  106. X        esac
  107. X    done
  108. X}
  109. X
  110. X
  111. Xshowstats () {
  112. X    echo "\nPSF INSTALLATION OPTIONS SELECTED"
  113. X    echo "--------------------------------"
  114. X    echo "printer selected from:   $PNAME"
  115. X    echo "printer page size is:    $PAGESIZE"
  116. X    echo "psf default options:     $PSFOPT"
  117. X    echo "banner options:          $BANNEROPT"
  118. X    echo "binaries and scripts in: $BINDIR"
  119. X    echo "man pages in chapter:    $MANCHAP"
  120. X}
  121. X
  122. Xcreateprinter () { 
  123. X    bdir="$BINDIR" 
  124. X    echo " "
  125. X    echo "Install PSF binaries and"
  126. X    ./query "   scripts in which directory [$bdir]? "
  127. X    read bdir
  128. X    case "$bdir" in
  129. X    '')    ;;
  130. X    *)    BINDIR="$bdir"
  131. X        ;;
  132. X    esac
  133. X    if test ! -d $BINDIR
  134. X    then
  135. X        echo "\nDirectory $BINDIR does not exist."
  136. X        echo "Create the directory and re-start the installation.\n"
  137. X        exit $FAIL
  138. X    fi
  139. X    echo "$BINDIR" > Pbindir.cfg
  140. X    cp $BINARIES $BINDIR
  141. X    cp $SCRIPTS  $BINDIR
  142. X    rm -f psf.model
  143. X    sed "s@BINARY@$BINDIR@g" psfxenix.LP | sed "s@OPTIONS@$PSFOPT@g" \
  144. X        | sed "s@BANNER@$BANNEROPT@g" > psf.model
  145. X    chmod +rw psf.model
  146. X    cp psf.model $MODEL/psf.model
  147. X    cp $PNAME $DEFDIR
  148. X    chown lp $MODEL/psf.model $DEFDIR
  149. X    chgrp bin $MODEL/psf.model $DEFDIR
  150. X
  151. X    showstats
  152. X    echo "\nNow use menu item 2 to install this printer with 'mkdev lp'."
  153. X    return 0
  154. X}
  155. X
  156. X
  157. Xgetsizes () {
  158. X    PAGESIZE=`cat Ppagesize.cfg`
  159. X    PNAME=`cat Ppsfprint.cfg`
  160. X    cp $PNAME psfprint.def
  161. X    case $PAGESIZE in
  162. X    DEFAULT)    PSFOPT= ;;
  163. X    *)        PSFOPT=`echo -g $PAGESIZE` ;;
  164. X    esac
  165. X    case $PAGESIZE in
  166. X    DEFAULT)    BANNEROPT= ;;
  167. X    *)        BANNEROPT=`echo -g $PAGESIZE` ;;
  168. X    esac
  169. X    return 0
  170. X}
  171. X
  172. Xreplaceprinter () { 
  173. X    selectdef $DEFFILES
  174. X    case $? in
  175. X    0)    ;;
  176. X    *)    return $?
  177. X    esac
  178. X    getsizes
  179. X    return 0
  180. X}
  181. X    
  182. X
  183. Xmanpages () { 
  184. X    echo "\nNormally, PSF man pages for xenix should be placed in the 'LOCAL'"
  185. X    echo "chapter.  Some sites prefer to use other chapters."
  186. X    cdir="$MANCHAP"
  187. X    echo " "
  188. X    ./query "Which chapter should be used for the PSF man pages [$cdir]? "
  189. X    read cdir
  190. X    case "$cdir" in
  191. X    '')    ;;
  192. X    *)    MANCHAP="$cdir"
  193. X        ;;
  194. X    esac
  195. X    if test ! -d /usr/man/man.$MANCHAP
  196. X    then
  197. X        echo "\nDirectory /usr/man/man.$MANCHAP does not exist."
  198. X        echo "Create the directory and re-start the manual installation.\n"
  199. X        exit $FAIL
  200. X    fi
  201. X
  202. X    cp  pmf.1 /usr/man/man.$MANCHAP/pmf.$MANCHAP
  203. X    cp  pnf.1 /usr/man/man.$MANCHAP/pnf.$MANCHAP
  204. X    cp  psf.1 /usr/man/man.$MANCHAP/psf.$MANCHAP
  205. X    cp  psd.1 /usr/man/man.$MANCHAP/psd.$MANCHAP
  206. X    cp  psman.1 /usr/man/man.$MANCHAP/psman.$MANCHAP
  207. X    cp  psnroff.1 /usr/man/man.$MANCHAP/psnroff.$MANCHAP
  208. X    cp  psmbox.1 /usr/man/man.$MANCHAP/psmbox.$MANCHAP
  209. X    man $MANCHAP pmf > /dev/null
  210. X    man $MANCHAP pnf > /dev/null
  211. X    man $MANCHAP psd > /dev/null
  212. X    man $MANCHAP psf > /dev/null
  213. X    man $MANCHAP psman > /dev/null
  214. X    man $MANCHAP psnroff > /dev/null
  215. X    man $MANCHAP psmbox > /dev/null
  216. X    echo "$MANCHAP" > Pmanchap.cfg
  217. X    echo "\nPSF man pages have been installed in /usr/man/man.$MANCHAP"
  218. X    return 0
  219. X}
  220. X
  221. Xprintman () {
  222. X    if test ! -d /usr/man/man.$MANCHAP
  223. X    then
  224. X        psf -2l 66 $DOCS | lp
  225. X    else
  226. X    psnroff -man $MANS
  227. X    fi
  228. X
  229. X    return 0
  230. X}
  231. X
  232. Xremoveall () {
  233. X    cdir="$MANCHAP"
  234. X    echo " "
  235. X    ./query "Remove PSF man pages from chapter [$cdir]? "
  236. X    read cdir
  237. X    case "$cdir" in
  238. X    '')    ;;
  239. X    *)    MANCHAP="$cdir"
  240. X        ;;
  241. X    esac
  242. X    if test ! -d /usr/man/man.$MANCHAP
  243. X    then
  244. X        echo "\nDirectory /usr/man/man.$MANCHAP does not exist."
  245. X        exit $FAIL
  246. X    fi
  247. X
  248. X    bdir="$BINDIR" 
  249. X    echo " "
  250. X    ./query "Remove PSF binaries+scripts from directory [$bdir]? "
  251. X    read bdir
  252. X    case "$bdir" in
  253. X    '')    ;;
  254. X    *)    BINDIR="$bdir"
  255. X        ;;
  256. X    esac
  257. X    if test ! -d $BINDIR
  258. X    then
  259. X        echo "\nDirectory $BINDIR does not exist."
  260. X        exit 1
  261. X    fi
  262. X
  263. X    rm -f  /usr/man/man.$MANCHAP/pmf.$MANCHAP
  264. X    rm -f  /usr/man/man.$MANCHAP/pnf.$MANCHAP
  265. X    rm -f  /usr/man/man.$MANCHAP/psf.$MANCHAP
  266. X    rm -f  /usr/man/man.$MANCHAP/psd.$MANCHAP
  267. X    rm -f  /usr/man/man.$MANCHAP/psman.$MANCHAP
  268. X    rm -f  /usr/man/man.$MANCHAP/psnroff.$MANCHAP
  269. X    rm -f  /usr/man/man.$MANCHAP/psmbox.$MANCHAP
  270. X
  271. X    rm -f  /usr/man/cat.$MANCHAP/pmf.$MANCHAP
  272. X    rm -f  /usr/man/cat.$MANCHAP/pnf.$MANCHAP
  273. X    rm -f  /usr/man/cat.$MANCHAP/psf.$MANCHAP
  274. X    rm -f  /usr/man/cat.$MANCHAP/psd.$MANCHAP
  275. X    rm -f  /usr/man/cat.$MANCHAP/psman.$MANCHAP
  276. X    rm -f  /usr/man/cat.$MANCHAP/psnroff.$MANCHAP
  277. X    rm -f  /usr/man/cat.$MANCHAP/psmbox.$MANCHAP
  278. X
  279. X    thisdir=`pwd`
  280. X
  281. X    cd $BINDIR
  282. X    rm $BINARIES $SCRIPTS
  283. X
  284. X    cd $thisdir
  285. X    
  286. X    rm $MODEL/psf.model
  287. X    rm $DEFDIR
  288. X
  289. X    return 0
  290. X}
  291. X
  292. X
  293. X#
  294. X# main()
  295. X#
  296. Xecho '\n\tPSF: Postscript print filter installation'
  297. Xwhile  
  298. X  mesg='\t1. Select printer type, install psf, make printer model.
  299. X    2. Install selected printer with  mkdev lp.
  300. X    3. Install man pages in /usr/man.
  301. X    4. Print man pages.
  302. X    5. Remove psf software and files from binary and spool directories.
  303. X
  304. XSelect an option '
  305. X  quit=quit
  306. Xdo
  307. X  prompt
  308. X  choice=$cmd
  309. X  quit="return to the previous menu"
  310. X  case $choice in
  311. X  1)    # select and install
  312. X    replaceprinter
  313. X    [ -r Ppagesize.cfg ] && [ -r Ppsfprint.cfg ] && [ -r $PNAME ] && createprinter
  314. X    ;;
  315. X  2)    mkdev lp
  316. X      ;;
  317. X  3)    manpages
  318. X    ;;
  319. X  4)      printman
  320. X      ;;
  321. X  5)    removeall
  322. X      ;;
  323. X  [qQ]) break ;;
  324. X  *)    error "unknown option: \"$choice\""
  325. X    ;;
  326. X  esac
  327. Xdone
  328. Xexit $OK
  329. END_OF_FILE
  330. if test 6508 -ne `wc -c <'Install.xenix'`; then
  331.     echo shar: \"'Install.xenix'\" unpacked with wrong size!
  332. fi
  333. chmod +x 'Install.xenix'
  334. # end of 'Install.xenix'
  335. fi
  336. if test -f 'Readme.Install' -a "${1}" != "-c" ; then 
  337.   echo shar: Will not clobber existing file \"'Readme.Install'\"
  338. else
  339. echo shar: Extracting \"'Readme.Install'\" \(6956 characters\)
  340. sed "s/^X//" >'Readme.Install' <<'END_OF_FILE'
  341. X               P S F     I N S T A L L A T I O N     (manual)
  342. X               =================================
  343. X                        and other notes
  344. X
  345. X   If you are using Xenix 2.3.x, you shoud be reading the file
  346. X   
  347. X           Readme.Xenix
  348. X
  349. X   and use:    Install.xenix
  350. X
  351. X   If yow are using AT&T Unix 3.2.2, you should be reading the file
  352. X
  353. X        Readme.Unix
  354. X
  355. X   and use:    Install.unix
  356. X
  357. X   If your are using a different system or wish to manually install psf,
  358. X   you are reading the correct file. (you might also wish to read
  359. X   Readme.Unix to get some additional information..)
  360. X
  361. X
  362. X
  363. XMANUAL INSTALLATION
  364. X^^^^^^^^^^^^^^^^^^^
  365. X
  366. X1. Edit the Makefile to reflect the binary target directory for the psf
  367. X   system.
  368. X
  369. X2. Psf requires a "printer definition file" named "psfprint.def" that
  370. X   describes the postscript printer. The file name is compiled into
  371. X   various psf modules. Edit the Makefile to provide the desired file
  372. X   path/name.
  373. X
  374. X3. Compile all sources with "make all".
  375. X
  376. X4. Generate a "printer definition file".  This is done by the
  377. X   command:
  378. X           selectdef defs/*.def
  379. X   
  380. X   "selectdef" will access all of printer definitions in the defs/
  381. X   directory and copy your selected printer definition into the current
  382. X   directory with a name of "psfprint.def" (or different name if you
  383. X   changed it in (2) above). The copy operation could be done manually
  384. X   - however you will not get a "psizes.ps" programme generated.
  385. X
  386. X   Selectdef also generates a postscript programme file "psizes.ps" that
  387. X   will print out the actual imageable area recorded in the printer roms
  388. X   for each page size known to your printer. The psizes.ps file should
  389. X   be sent to the printer with:
  390. X   
  391. X           cat psizes.ps | lp
  392. X       or
  393. X           cat psizes.ps > /dev/lp
  394. X   
  395. X   The resulting figures can be used to modify the psfprint.def file to
  396. X   accurately define your printer's imageable area.
  397. X
  398. X   Even though the various defs/*.def files are derived from the Adobe
  399. X   .ppd files, the .ppd files for the printers do not necessarily
  400. X   reflect the accurate imageable areas actually implemented by the
  401. X   printer manufacturer. For example, the NEC__470.ppd file provided by
  402. X   Adobe does not describe the imageable area that is actually in my
  403. X   LC890. Thus, psizes.ps is a handy way to determine your
  404. X   exact printer imageable area.
  405. X
  406. X   If your printer is not known in the various defs/*.def files, then
  407. X   choose the closest approximation.  
  408. X   
  409. X   If that is not good enough, you should modify the postscript
  410. X   programme at the end of this Readme file (or use the psizes.ps
  411. X   generated for the "closest approximation") to reflect the various
  412. X   paper sizes supported by your printer. Send the resulting programme
  413. X   to the printer, and construct a psfprint.def file based upon it's
  414. X   results. Use the "sample.def" file as a starting point to generate
  415. X   your .def file.
  416. X
  417. X5. Copy the desired psf binaries and scripts to the binary directory
  418. X   (as per the Makefile definition).  Probably "selectdef" and "table"
  419. X   should NOT be copied.  (or use "make all").
  420. X
  421. X   If you are not using Letter size paper as your standard, you may need
  422. X   to make some modifications to the scripts as described in (11) below.
  423. X
  424. X6. Copy the "psfprint.def" printer definition file to the target file 
  425. X   (as per the Makefile definition).  (also copied with "make all").
  426. X
  427. X7. If you intend to run psf as part of the print spooler, then copy
  428. X   "psfsample.LP" to another file. Edit this new file to configure the
  429. X   printer model. 
  430. X   
  431. X   If you have a serial printer, examine the stty command to ensure
  432. X   correct port configuration.
  433. X   
  434. X   Install the printer model as needed for your printer system. If your
  435. X   spooler allows passing of printer options with the "-o" option, then
  436. X   you could use (for example):
  437. X
  438. X        lp -o"-4xh" this.file that.file
  439. X        
  440. X   The "-4xh" options are passed by lp to psf to print the files "4-up"
  441. X   on a page, with file name headers (h) and dividing lines between
  442. X   quandrants (x). Any set of options may be enclosed between the
  443. X   quotation marks.
  444. X
  445. X
  446. X8. If you do not intend to run psf as part of the spooler, you
  447. X   are finished.  psf is then used as a print filter manually.
  448. X   
  449. X   For example:
  450. X
  451. X        psf this.file | lp
  452. X   
  453. X           man -b vi | pnf -i | psf -2 | lp
  454. X
  455. X9. Install the man pages.  E.g.:   cp *.1 /usr/man/man.1
  456. X
  457. X10. Print the man pages:     E.g.:   psnroff -man *.1
  458. X    or, if nroff is not avaliable:   psf -2l 66 *.doc | lp
  459. X
  460. X11. Make any option changes to the various psf commands
  461. X    in scripts.  For example:
  462. X    
  463. X    psman:        change the man chapters as per your man directories
  464. X                  (the distribution psman assumes Xenix directories)
  465. X    psnroff:      change the psf options (by default, the output
  466. X                  default is for two-up printing).
  467. X    psmbox:       change default psf printing characteristics.
  468. X    psbanner.c:   this routine prints banner pages.  you may
  469. X                  wish to change the layout of banner pages.
  470. X
  471. X   If European paper sizes are used (A4, B5, etc), then the "-l nn" for
  472. X   psf or the "-r nn -l nn" option to pnf may need to be specified.
  473. X
  474. X12. Edit the file "Testfile":  this file, (after editing) is an example
  475. X    of how escape seqeuences can be imbedded in a text file to allow
  476. X    direct font control within a text editor (See psf.1 for details).
  477. X
  478. X   The "Testfile" should contain many ^E characters (octal \005).  Since
  479. X   mail/news system may change the ^E character into the text string "005"
  480. X   You will have to edit the Testfile and replace all "005" strings with
  481. X   true ctrl-E character.
  482. X
  483. X   One easy way to correct this is with sed:
  484. X
  485. X    sed 's@005@<CTRL-E>@g' Testfile > newtest
  486. X                   +------+
  487. X                    actually type the CTRL-E character
  488. X                    to generate the octal charcter \005
  489. X
  490. X    After editing, do the following:
  491. X    
  492. X        psf newtest | lp
  493. X    
  494. X    to see how font control can work in a text file.
  495. X
  496. X=========================================================================        
  497. X
  498. X   You can modify the following postscript programme (quickly now, rush
  499. X   out and buy some postscript manuals....) to print out (on paper) the
  500. X   imageable area of the various paper sizes. Normally, this file is
  501. X   generated by "selectdef" and is named psizes.ps.
  502. X
  503. X
  504. X%!
  505. X/getsize {
  506. X    clippath
  507. X    pathbbox
  508. X} def
  509. X/sendsize {
  510. X    /ury exch def
  511. X    /urx exch def
  512. X    /lly exch def
  513. X    /llx exch def
  514. X    /str 64 string def
  515. X    show
  516. X    (  ) show
  517. X    llx    ceiling cvi str cvs show
  518. X    (  ) show
  519. X    lly    ceiling cvi str cvs show
  520. X    (  ) show
  521. X    urx    floor cvi str cvs show
  522. X    (  ) show
  523. X    ury    floor cvi str cvs show
  524. X} def
  525. X/pg save def
  526. Xnewpath
  527. Xb5
  528. X(B5: 516 729) getsize
  529. Xa4
  530. X(A4: 595 842) getsize
  531. Xlegal
  532. X(Legal: 612 1008) getsize
  533. Xletter
  534. X(Letter: 612 792) getsize
  535. Xstatusdict begin lettertray end
  536. X/Courier findfont 12 scalefont setfont
  537. X50 600 moveto
  538. X(Imageable area) show
  539. X50 585 moveto
  540. X(NEC LC-890 v47.0 \(corrected\)) show
  541. X50 565 moveto
  542. Xsendsize
  543. X50 550 moveto
  544. Xsendsize
  545. X50 535 moveto
  546. Xsendsize
  547. X50 520 moveto
  548. Xsendsize
  549. Xshowpage 
  550. Xpg restore
  551. END_OF_FILE
  552. if test 6956 -ne `wc -c <'Readme.Install'`; then
  553.     echo shar: \"'Readme.Install'\" unpacked with wrong size!
  554. fi
  555. # end of 'Readme.Install'
  556. fi
  557. if test -f 'Readme.Xenix' -a "${1}" != "-c" ; then 
  558.   echo shar: Will not clobber existing file \"'Readme.Xenix'\"
  559. else
  560. echo shar: Extracting \"'Readme.Xenix'\" \(6949 characters\)
  561. sed "s/^X//" >'Readme.Xenix' <<'END_OF_FILE'
  562. X                   P S F     I N S T A L L A T I O N   (Xenix 2.x)
  563. X                   =================================
  564. X
  565. X   First examine the Makefile to esure that the compilation options are
  566. X   as needed for your system.  Then compile the source code with "make all".
  567. X
  568. X   If psf is being used with a serial postscript printer, examine the
  569. X   psfxenix.LP file and make any needed modifications to the stty
  570. X   command that sets up the serial port. The psfxenix.LP file is the
  571. X   prototype printer model that will eventually be copied to
  572. X   /usr/spool/lp/model.
  573. X
  574. X   If on-line man pages are not available, the printing of the man
  575. X   pages will use preformatted *.doc files.
  576. X   
  577. X   You might also wish to read the "Readme.Install" file.
  578. X
  579. X   PSF is installed with the Install.xenix script. To do so, you must
  580. X   be root (to allow the creation of various files and directories).
  581. X
  582. X   The Install.xenix script asks:
  583. X
  584. X    1. Select printer type, install psf, make printer model.
  585. X    2. Install selected printer with  mkdev lp.
  586. X    3. Install man pages in /usr/man.
  587. X    4. Print man pages.
  588. X    5. Remove psf software and files from binary and spool directories.
  589. X
  590. X     ===> Select an option or enter q to quit:
  591. X   
  592. X   First select option 1: this allows you to configure psf to your
  593. X   postscript printer. The list is presented as follows:
  594. X
  595. X                         SELECT PRINTER TYPE
  596. X
  597. X 1: Apple LaserWriter v23.0             2: Apple LaserWriter Plus v38.0       
  598. X 3: Apple LaserWriter Plus v42.2        4: AST TurboLaser/PS v47.0            
  599. X 5: Agfa-Compugraphic 9400P v49.3       6: Dataproducts LZR-2665 v47.0        
  600. X 7: Dataproducts LZR 1260 v47.0         8: IBM 4216-020 v47.0                 
  601. X 9: IBM 4216-030 v50.5                 10: Linotronic 100 v38.0               
  602. X11: Linotronic 100 v42.5               12: Linotronic 200 v47.1               
  603. X13: Linotronic 200 v49.3               14: Linotronic 300 v47.0               
  604. X15: Linotronic 300 v47.1               16: Linotronic 300 v49.3               
  605. X17: Linotronic 500 v49.3               18: Apple LaserWriter II NT v47.0      
  606. X19: Apple LaserWriter II NTX v47.0     20: NEC LC-890 v47.0 (corrected)       
  607. X21: NEC LC-890 v47.0                   22: QMS-PS 810 v47.0                   
  608. X23: QMS-PS 800 v46.1                   24: QMS-PS 800 Plus v46.1              
  609. X25: QMS ColorScript 100 v49.3          26: Qume ScripTEN v47.0                
  610. X27: Schlumberger 5232 Color PostScript Printer v50.3
  611. X28: TI OmniLaser 2108 v45.0            29: TI Omnilaser 2115 v47.0            
  612. X30: Varityper 4200B-P v49.3            31: Varityper 4300P v49.3              
  613. X32: Varityper VT-600P v48.0            33: Varityper VT-600W v48.0            
  614. X==> Select printer by number (q = quit, r = refresh display): 
  615. X
  616. X   After the printer type is selected, you are asked to specify the
  617. X   default paper size that psf will assume unless otherwise instructed:
  618. X
  619. X    Select default page size:
  620. X      1: Letter
  621. X      2: Legal
  622. X      3: A4
  623. X      4: B5
  624. X     ==> Select page size by number (q = quit, r = refresh display): 
  625. X
  626. X   (The list of page sizes is dependent upon the selected printer type.
  627. X   As a result, the list may differ from the above sample)
  628. X
  629. X
  630. X   The destination directory for the PSF binaries and script files must
  631. X   be specified. By default, the destination is /usr/bin. You may
  632. X   specify any other directory (such as /usr/local/bin, etc). The only
  633. X   requirement is that the various uses of PSF are pathed to the
  634. X   specified directory.
  635. X
  636. X       Install PSF Binaries and 
  637. X           scripts in which directory [/usr/bin]? 
  638. X
  639. X
  640. X   The various binaries, scripts and printer defintion files are then
  641. X   copied to the appropriate target directories. An appropriate printer
  642. X   model is copied to /usr/spool/lp/model.
  643. X
  644. X   At this point, you may now quit the installation process if you wish.
  645. X   If you quit now, then you will have to use "mkdev lp" to install your
  646. X   printer. The PSF postscript printer is a selectable printer type in
  647. X   "mkdev lp".
  648. X
  649. X
  650. X   Optionally, you can continue with the installation by selecting
  651. X   option 2 from:
  652. X
  653. X    1. Select printer type, install psf, make printer model.
  654. X    2. Install selected printer with  mkdev lp.
  655. X    3. Install man pages in /usr/man.
  656. X    4. Print man pages.
  657. X    5. Remove psf software and files from binary and spool directories.
  658. X
  659. X   This will invoke "mkdev lp" for you.
  660. X
  661. X
  662. X   The PSF installation directory in /tmp/psf is NOT automatically
  663. X   deleted. You must remove this directory manually or copy it to a
  664. X   suitable "save" directory before deletion.
  665. X
  666. X   If you have the text processing system installed with man pages, then
  667. X   you may use option 3 to install the on line man pages. 
  668. X   
  669. X   With option 4, you may print a copy of the man pages. (Printing will
  670. X   used the pre-formatted *.doc files if on line man pages are not
  671. X   available)
  672. X
  673. X
  674. XAFTER INSTALLATION
  675. X^^^^^^^^^^^^^^^^^^
  676. X   Edit the file "Testfile":  this file, (after editing) is an example
  677. X   of how escape seqeuences can be imbedded in a text file to allow
  678. X   direct font control within a text editor (See psf.1 for details).
  679. X
  680. X   The "Testfile" should contain many ^E characters (octal \005).  Since
  681. X   mail system may change the ^E character into the text string "005"
  682. X   You will have to edit the testfile and replace all "005" strings with
  683. X   true ctrl-E character.
  684. X
  685. X   One easy way to correct this is with sed:
  686. X
  687. X    sed 's@005@<CTRL-E>@g' Testfile > testfile
  688. X                    +-----+
  689. X                    actually type the CTRL-E character
  690. X                    to generate the octal charcter \005
  691. X
  692. X    After editing, do the following:
  693. X    
  694. X        psf testfile | lp
  695. X    
  696. X    to see how font control can work in a text file.
  697. X
  698. X
  699. X
  700. X
  701. XPSF notes.
  702. X
  703. X   The printer definitions in ~psf/defs are derived from the Adobe
  704. X   ".ppd" files. These are available from the Adobe file server via
  705. X   email. The programme "table" is used to translate the ".ppd" files
  706. X   into ".def" printer definition files used by psf.
  707. X
  708. X   If the user's printer is not in the list of available printers, a
  709. X   suitable .def definition must be manually constructed (see file
  710. X   "sample.def" as a guide).
  711. X
  712. X
  713. XPROBLEMS:
  714. X  
  715. X   The adobe .ppd files not not necessarily describe the "true"
  716. X   printable area of the printers. For example, the printable area of a
  717. X   NEC LC890 printer is different than described in the nec_lc890.ppd
  718. X   file. I do not know which .ppd files are "accurate" or "inaccurate"!
  719. X
  720. X   To determine actual imageable area for your printer, you should send
  721. X   file "psizes.ps" to the printer. Then read the notes in the
  722. X   Readme.Install file (in particular, point 4).
  723. X
  724. X   If PSF is to be used over uucp/micnet connections, then the spooler
  725. X   backend should ensure that the "-o" options are properly quoted.
  726. X   It must pass the options such as:
  727. X   
  728. X           -o"-g Legal -m 72"
  729. X   
  730. X   properly to the remote printer.  Alternatively, the local machine
  731. X   could wrap the postscript and simply send results to the remote
  732. X   printer without worrying about the -o options.
  733. END_OF_FILE
  734. if test 6949 -ne `wc -c <'Readme.Xenix'`; then
  735.     echo shar: \"'Readme.Xenix'\" unpacked with wrong size!
  736. fi
  737. # end of 'Readme.Xenix'
  738. fi
  739. if test -f 'pmf.c' -a "${1}" != "-c" ; then 
  740.   echo shar: Will not clobber existing file \"'pmf.c'\"
  741. else
  742. echo shar: Extracting \"'pmf.c'\" \(6418 characters\)
  743. sed "s/^X//" >'pmf.c' <<'END_OF_FILE'
  744. X/* ta=4 */
  745. X/****************************************************************************
  746. X*                            p m f . c        v2.0                            *
  747. X*                                                                            *
  748. X*    postscript mail filter                                                    *
  749. X*                                                                            *
  750. X*    very simple mail filter to print name and subject in bold letters        *
  751. X*    for psf usage.  Generates escape sequences that psf can understand.        *
  752. X*    Modify the code if you wish to have various headers ignored for print.    *
  753. X*                                                                            *
  754. X*    Copyright: 1989-Feb, Tony Field.       tony@ajfcal                        *
  755. X****************************************************************************/
  756. X/* revision history:
  757. X
  758. X    1989-May-20        allow input from multiple file names as well as stdin
  759. X*/
  760. X
  761. X#include <stdio.h>
  762. X#include <string.h>
  763. X#include <ctype.h>
  764. X#include "patchlevel.h"
  765. X#include "psf.h"
  766. X
  767. X#define MAX_C                62            /*    max char wrap point on mail header line    */
  768. X
  769. Xchar    *pgmname;
  770. X
  771. Xmain (argc, argv)
  772. Xint        argc;
  773. Xchar    *argv[];
  774. X{
  775. X    int        ignore_garbage, i;
  776. X    extern char *optarg;
  777. X    extern int    optind;
  778. X    FILE    *input_fp;
  779. X
  780. X    pgmname = argv[0];    
  781. X    ignore_garbage = 1;
  782. X    if (strcmp (argv[1], "-") == 0)
  783. X        usage();
  784. X    while ((i = getopt(argc, argv, "s-")) != -1)
  785. X    {    switch (i)
  786. X        {
  787. X        case 's':
  788. X            ignore_garbage = 0;        /*    print all headers    */
  789. X            break;
  790. X
  791. X        default:
  792. X            usage ();
  793. X        }
  794. X    }
  795. X    if (optind >= argc)
  796. X    {    input_fp = stdin;
  797. X        print_file (input_fp, ignore_garbage);
  798. X    }
  799. X    else
  800. X    {
  801. X        for ( i = 0;  optind < argc;  optind++)
  802. X        {    if ((input_fp = fopen (argv[optind], "r")) == NULL)
  803. X            {    fprintf (stderr, "%s: File %s not found\n", pgmname, argv[optind]);
  804. X            }
  805. X            else
  806. X            {    if (i)
  807. X                    send ("\f");
  808. X                print_file (input_fp, ignore_garbage);
  809. X                fclose (input_fp);
  810. X                i++;
  811. X            }
  812. X        }
  813. X    }
  814. X    exit (0);
  815. X}
  816. X
  817. Xprint_file (fp, ignore_garbage)
  818. XFILE *fp;
  819. Xint     ignore_garbage;
  820. X{
  821. X    char    line[900], first[100], tail[800], *strchr();
  822. X    int        i, many, nchar, last_char, header, garbage;
  823. X
  824. X    header = garbage = 0;
  825. X    while (fgets (line, 999, fp)  != NULL)
  826. X    {
  827. Xnewmail:
  828. X        last_char = split (line, first, tail);
  829. X
  830. X        /*    The following headers will be ignored during printing    */
  831. X        
  832. X        if (ignore_garbage 
  833. X            &&  (strcmp (first, "Distribution:"  ) == 0
  834. X            ||   strcmp (first, "Keywords:"      ) == 0
  835. X            ||   strcmp (first, "Lines:"         ) == 0
  836. X            ||   strcmp (first, "Message-ID:"    ) == 0
  837. X            ||   strcmp (first, "Message-Id:"    ) == 0
  838. X            ||   strcmp (first, "News-Path:"     ) == 0
  839. X            ||   strcmp (first, "Path:"          ) == 0
  840. X            ||   strcmp (first, "Posted:"        ) == 0
  841. X            ||   strcmp (first, "Received:"      ) == 0
  842. X            ||   strcmp (first, "References:"    ) == 0
  843. X            ||   strcmp (first, "Sender:"        ) == 0
  844. X            ||   strcmp (first, "Status:"        ) == 0
  845. X            ||   strncmp(first, "X-",          2 ) == 0))
  846. X        {    garbage = 1;
  847. X        }
  848. X        else if (strcmp (first, "From") == 0)
  849. X        {    printclean (first, tail);
  850. X            garbage = 0;
  851. X        }
  852. X        else if (strcmp (first, "From:") == 0
  853. X                ||  strcmp (first, "Reply-To:") == 0
  854. X                ||  strcmp (first, "To:") == 0)
  855. X        {    header = 1;
  856. X            if ((strchr (tail, '(') == NULL)  &&  (strchr (tail, '<') == NULL))
  857. X                printbold (first, tail);
  858. X            else
  859. X                printname (first, tail);
  860. X            garbage = 0;
  861. X        }
  862. X        else if (strcmp (first, "Bcc:") == 0 ||  strcmp (first, "Cc:") == 0)
  863. X        {    header = 1;
  864. X            printname (first, tail);
  865. X            garbage = 0;
  866. X        }
  867. X        else if (strcmp (first, "Subject:") == 0)
  868. X        {    printsubject (first, tail);
  869. X            garbage = 0;
  870. X        }
  871. X        else if (last_char == ':')
  872. X        {
  873. X            header = 1;
  874. X            printclean (first, tail);
  875. X            garbage = 0;
  876. X        }
  877. X        else if (empty (line))
  878. X        {    
  879. X            send ("\n");
  880. X            while (fgets (line, 999, fp) != NULL)
  881. X            {    if (strncmp (line, "From ", 5) == 0
  882. X                    &&  (strchr (line, ':') < strrchr (line, ':')))
  883. X                {    send ("\f");
  884. X                    goto newmail;    /* goto's considered harmful since 1964 */
  885. X                }
  886. X                printf ("%s", line);
  887. X            }
  888. X            break;
  889. X        }
  890. X        else if (garbage == 0)
  891. X            printclean (" ", line);
  892. X    }
  893. X}
  894. X
  895. Xprintclean (first, tail)
  896. Xchar    *first, *tail;
  897. X{
  898. X    printf ("%-14s", first);
  899. X    printlong (tail);
  900. X}
  901. X
  902. Xprintlong (tail)
  903. Xchar    *tail;
  904. X{    char    *c, *prefix;
  905. X    int        marks[100], nmarks, i, j, nchar;
  906. X
  907. X    /*    locate all marks that can be use for a line break     */
  908. X
  909. X    marks[0] = 0;
  910. X    marks[1] = 0;
  911. X    c = tail;
  912. X    for ( i = nchar = 0, nmarks = 1;  nmarks < 100;  i++, c++, nchar++)
  913. X    {
  914. X        if (*c == '!'  ||  *c == ' ' ||  *c == '<'  
  915. X            ||  *c == '('  ||  *c == '\0')
  916. X        {    if (nchar < MAX_C)
  917. X                marks[nmarks] = i;
  918. X            else
  919. X            {    nchar = i - marks[nmarks];
  920. X                marks[++nmarks] = i;
  921. X            }
  922. X            if (*c == '\0')
  923. X                break;
  924. X        }
  925. X    }
  926. X    marks[nmarks] = i;
  927. X    for (i = 0;  i < nmarks;  i++)
  928. X    {
  929. X        if (i)
  930. X            printf ("%-14s", " ");
  931. X        for (j = marks[i];  j < marks[i+1];  j++)
  932. X            putchar (tail[j]);
  933. X        putchar ('\n');
  934. X    }
  935. X}
  936. X
  937. Xprintsubject (first, tail)
  938. Xchar    *first, *tail;
  939. X{
  940. X    printf ("%-14s", first);
  941. X    send (BEGIN_SUBJECT);
  942. X    send (tail);
  943. X    send (END_SUBJECT);
  944. X    send ("\n");
  945. X}
  946. X
  947. Xprintbold (first, tail)
  948. Xchar    *first, *tail;
  949. X{
  950. X    printf ("%-14s", first);
  951. X    send (BEGIN_BOLD);
  952. X    printlong (tail);
  953. X    send (END_BOLD);    
  954. X}
  955. X
  956. Xprintname (first, tail)
  957. Xchar    *first, *tail;
  958. X{
  959. X    printf ("%-14s", first);
  960. X
  961. X    if (strchr (tail, '<') != NULL)
  962. X    {    /*    address syntax "name <address> stuff" */
  963. X        send (BEGIN_NAME);
  964. X        while (*tail != '<')
  965. X            putchar (*tail++);
  966. X        send (END_NAME);
  967. X        putchar (*tail++);
  968. X        while (*tail)
  969. X        {    putchar (*tail);
  970. X            if (*tail++ == '>')
  971. X            {    if (*tail)
  972. X                {    send (BEGIN_NAME);
  973. X                    while (*tail)
  974. X                        putchar (*tail++);
  975. X                    send (END_NAME);
  976. X                }
  977. X            }
  978. X        }
  979. X    }
  980. X    else
  981. X    {    /*    address syntax "address (name)" */
  982. X        while (*tail  &&  *tail != '(')
  983. X            putchar (*tail++);
  984. X        if (*tail)
  985. X        {    send (BEGIN_NAME);
  986. X            putchar (*tail++);
  987. X            while (*tail)
  988. X            {    putchar (*tail);
  989. X                if (*tail++ == ')')
  990. X                {    send (END_NAME);
  991. X                    while (*tail)
  992. X                        putchar (*tail++);
  993. X                    putchar ('\n');
  994. X                    return;
  995. X                }
  996. X            }
  997. X        }
  998. X    }
  999. X    putchar ('\n');
  1000. X}
  1001. X
  1002. Xsend (s)
  1003. Xchar    *s;
  1004. X{
  1005. X    while (*s)
  1006. X        putchar (*s++);
  1007. X}
  1008. X
  1009. Xempty (s)
  1010. Xchar    *s;
  1011. X{    while (*s  &&  *s <= ' ')
  1012. X        s++;
  1013. X    if (*s)
  1014. X        return (0);
  1015. X    else
  1016. X        return (1);
  1017. X}
  1018. X
  1019. Xsplit (line, first, tail)
  1020. Xchar    *line;            /*    input:    full input line            */
  1021. Xchar    *first;            /*    return:    first word of line        */
  1022. Xchar    *tail;            /*    return:    all others words of line*/
  1023. X{    int    last;
  1024. X
  1025. X    last = 0;
  1026. X    while (*line  &&  isspace (*line) == 0)
  1027. X    {    last = *line;
  1028. X        *first++ = *line++;
  1029. X    }
  1030. X    *first = '\0';
  1031. X    
  1032. X    while (*line  &&  isspace (*line))
  1033. X        line++;
  1034. X    
  1035. X    while (*line  &&  *line != '\n')
  1036. X        *tail++ = *line++;
  1037. X    *tail = '\0';
  1038. X    *line = '\0';
  1039. X    return (last);
  1040. X}
  1041. X
  1042. Xusage ()
  1043. X{
  1044. X    fprintf (stderr, "Usage:   pmf [-s] files... >out.file\n");
  1045. X    fprintf (stderr, " where        -s  = show all header lines\n");
  1046. X    fprintf (stderr, "            files = input files (or stdin)\n");
  1047. X    exit (0);    
  1048. X}
  1049. END_OF_FILE
  1050. if test 6418 -ne `wc -c <'pmf.c'`; then
  1051.     echo shar: \"'pmf.c'\" unpacked with wrong size!
  1052. fi
  1053. # end of 'pmf.c'
  1054. fi
  1055. if test -f 'pnf.c' -a "${1}" != "-c" ; then 
  1056.   echo shar: Will not clobber existing file \"'pnf.c'\"
  1057. else
  1058. echo shar: Extracting \"'pnf.c'\" \(6253 characters\)
  1059. sed "s/^X//" >'pnf.c' <<'END_OF_FILE'
  1060. X/* ta=4 */
  1061. X/****************************************************************************
  1062. X*                            p n f . c      v2.0                                *
  1063. X*                                                                            *
  1064. X*    postscript filter for nroff'ed text                                        *
  1065. X*                                                                            *
  1066. X*    Translate backspaces in nroff documents to either BOLD or UNDERLINE        *
  1067. X*    for psf usage                                                            *
  1068. X*                                                                            *
  1069. X*    Copyright: 1989-Feb, Tony Field.       tony@ajfcal                        *
  1070. X****************************************************************************/
  1071. X/* revision history:
  1072. X
  1073. X    1989-Jun-15        Added -l linecount. For nroff, suppress 3 blank lines 
  1074. X                    between nroff'ed pages.    
  1075. X                    
  1076. X                    Corrected a very stupid programming mistake with how[i-1].
  1077. X
  1078. X                    Correct problem if "bold" is adjacent to "underline"
  1079. X
  1080. X                    Removed -x option.  user must "man -b".
  1081. X
  1082. X    1989-May-20        Allow input from multiple file names as well as stdin
  1083. X*/
  1084. X
  1085. X/*    For each line in of input text, scan for backspaces.  Determine if
  1086. X    the operation is an underline (i.e. the preceeding character is
  1087. X    the "_") or if it is a bolding (the character after the underscore
  1088. X    is the same as the preceeding.
  1089. X    
  1090. X    Generate the sequence \005B..text..\005b   for bold
  1091. X                          \005U..text..\005u   for underline
  1092. X                          \005I..text..\005i   for italics
  1093. X
  1094. X    Since the text from nroff does not have a decent way of identifying
  1095. X    italics, you may make the decision to generate the "italic" or 
  1096. X    "underline" escape sequence  whenever an underline is detected in
  1097. X    the output.  Italic fonts look nicer than the underlines 2-up.
  1098. X
  1099. X    The logic cannot handle bold-underlined (nor italic-underlined).
  1100. X    This could be done with a bit of extra logic to manipulate bits
  1101. X    in the "how" vector.
  1102. X
  1103. X    For nroff, remove three blank lines between pages (an nroff'ed
  1104. X        document, letter size, has 66 lines.  the postscript
  1105. X        printer must see 63 lines.)   Assume that nroff is consistent.
  1106. X        If "point size" adjustments are made (e.g. some documents
  1107. X        originally intended for troff), then lines per page may not
  1108. X        be consistent.
  1109. X        
  1110. X*/
  1111. X
  1112. X#include <stdio.h>
  1113. X#include "psf.h"
  1114. X#include "patchlevel.h"
  1115. X
  1116. Xchar    *pgmname;
  1117. X
  1118. Xmain (argc, argv)
  1119. Xint        argc;
  1120. Xchar    *argv[];
  1121. X{    int        i, c;
  1122. X    int        nroff_lines = 66;
  1123. X    int        remove = 3;
  1124. X    int        count_lines = 1;
  1125. X    char    *underline_on, *underline_off;
  1126. X    extern char *optarg;
  1127. X    extern int    optind;
  1128. X    FILE    *input_fp;
  1129. X    
  1130. X    pgmname = argv[0];
  1131. X    underline_on  = BEGIN_UNDERLINE;
  1132. X    underline_off = END_UNDERLINE;
  1133. X
  1134. X    if (strcmp (argv[1], "-") == 0)
  1135. X        usage();
  1136. X    while ((c = getopt(argc, argv, "ifr:l:-")) != -1)
  1137. X    {    switch (c)
  1138. X        {
  1139. X        case 'i':
  1140. X            underline_on  = BEGIN_ITALICS;
  1141. X            underline_off = END_ITALICS;
  1142. X            break;
  1143. X        
  1144. X        case 'l':
  1145. X            nroff_lines = atoi (optarg);
  1146. X            break;
  1147. X            
  1148. X        case 'r':
  1149. X            remove = atoi (optarg);
  1150. X            break;
  1151. X            
  1152. X        case 'f':
  1153. X            count_lines = 0;
  1154. X            break;
  1155. X            
  1156. X        default:
  1157. X            usage ();
  1158. X        }
  1159. X    }
  1160. X    
  1161. X    if (optind >= argc)
  1162. X    {    input_fp = stdin;
  1163. X        print_file (input_fp, nroff_lines, remove, underline_on, underline_off, count_lines);
  1164. X    }
  1165. X    else
  1166. X    {
  1167. X        for (i = 0 ;  optind < argc;  optind++)
  1168. X        {    if ((input_fp = fopen (argv[optind], "r")) == NULL)
  1169. X            {    fprintf (stderr, "%s: File %s not found\n", pgmname, argv[optind]);
  1170. X            }
  1171. X            else
  1172. X            {    if (i)
  1173. X                    send ("\f");
  1174. X                print_file (input_fp, nroff_lines, remove, underline_on, underline_off, count_lines);
  1175. X                fclose (input_fp);
  1176. X                i++;
  1177. X            }
  1178. X        }
  1179. X    }
  1180. X    exit (0);
  1181. X        
  1182. X}
  1183. X
  1184. Xprint_file (fp, nroff_lines, remove, underline_on, underline_off, count_lines)
  1185. XFILE    *fp;
  1186. Xint        nroff_lines;
  1187. Xint        remove;
  1188. Xint        count_lines;
  1189. Xchar    *underline_on, *underline_off;
  1190. X{
  1191. X    int        c, n, i;
  1192. X    int        how[401];
  1193. X    char    line[401];
  1194. X    char    buf[401];
  1195. X    int        ii;
  1196. X    int        nroff_count;
  1197. X    int        insert_two = 0;
  1198. X
  1199. X    nroff_count = n = 0;
  1200. X    
  1201. X    clear (line, how, 400);
  1202. X    while (( c = fgetc (fp)) != EOF)
  1203. X    {
  1204. X        if (c == '\033')            /* if ESCAPE character, then handle */
  1205. X        {    if ((c = fgetc (fp)) == EOF)
  1206. X                break;
  1207. X            if (c == '9')        /*    1/2 line space fwd                */
  1208. X            {    putchar (ESCAPE);
  1209. X                putchar ('+');
  1210. X                nroff_count += 5;
  1211. X                continue;
  1212. X            }
  1213. X            else if (c == '8')        /*    1/2 line space back            */
  1214. X            {    putchar (ESCAPE);
  1215. X                putchar ('-');
  1216. X                nroff_count -= 5;
  1217. X                continue;
  1218. X            }
  1219. X            else
  1220. X            {
  1221. X                continue;
  1222. X            }
  1223. X        }
  1224. X            
  1225. X        else if (c == '\b')
  1226. X            n--;
  1227. X        else if (c == '\n')
  1228. X        {    if (count_lines)
  1229. X            {    /*    remove 3 blank lines between pages
  1230. X                    1 from beginning of page,
  1231. X                    2 from end of page.
  1232. X                */
  1233. X                nroff_count = (nroff_count + 10) % (nroff_lines * 10);
  1234. X                if (nroff_count < 20  ||  nroff_count > (nroff_lines - (remove-1)) * 10)
  1235. X                    continue;
  1236. X            }
  1237. X            how[n] = 0;
  1238. X            line[n] = 0;
  1239. X            for (i = 0;  i <= n;  i++)
  1240. X            {
  1241. X                if (how[i])
  1242. X                {    /*    either bold or underlined see if previous char
  1243. X                        is not escaped - indicates the beginning of 
  1244. X                        an escape sequence.  may need to terminate
  1245. X                        previous sequence first (e.g. bold followed
  1246. X                        by underlined).
  1247. X                    */
  1248. X                    if (i > 0  &&  how[i-1]  &&  (how[i] != how[i-1]))
  1249. X                    {    if (how[i-1] == 1)
  1250. X                            send (END_BOLD);
  1251. X                        else
  1252. X                            send (underline_off);
  1253. X                    }
  1254. X                    if (how[i] == 1  &&  (i == 0  ||  how[i-1] != 1))
  1255. X                        send (BEGIN_BOLD);
  1256. X                    else if (how[i] == 2  &&  (i == 0  ||  how[i-1] != 2))
  1257. X                        send (underline_on);
  1258. X                }
  1259. X                else    /* zero means just a character, unmodified */
  1260. X                {    /* are we at the end of an escape sequence? */
  1261. X                    if (i > 0)
  1262. X                    {    if (how[i-1] == 1)
  1263. X                            send (END_BOLD);
  1264. X                        else if (how[i-1] == 2)
  1265. X                            send (underline_off);
  1266. X                    }
  1267. X                }
  1268. X                if (line[i])
  1269. X                    putchar (line[i]);
  1270. X            }
  1271. X            putchar ('\n');    
  1272. X            clear (line, how, n);
  1273. X            n = 0;
  1274. X        }
  1275. X        else
  1276. X        {    if (line[n])
  1277. X            {    if (line[n] == c)        /* same character?        */
  1278. X                    how[n] = 1;            /*    yes:    bold        */
  1279. X                else
  1280. X                    how[n] = 2;            /*    no:        underline    */
  1281. X            }
  1282. X            line[n++] = c;
  1283. X        }
  1284. X    }
  1285. X}
  1286. X
  1287. Xclear (line, how, n)
  1288. Xchar    *line;
  1289. Xint        *how;
  1290. Xint        n;
  1291. X{
  1292. X    int        i;
  1293. X    
  1294. X    for (i  = 0;  i <= n;  i++)
  1295. X    {    line[i] = '\0';
  1296. X        how[i] = 0;
  1297. X    }
  1298. X}
  1299. X
  1300. Xsend (s)
  1301. Xchar    *s;
  1302. X{
  1303. X    while (*s)
  1304. X        putchar (*s++);
  1305. X}
  1306. X
  1307. Xusage ()
  1308. X{
  1309. X    fprintf (stderr, "Usage:   pnf [-i] [ -f ] [ -l n ] [ -r n ] file ... >out.file\n");
  1310. X    fprintf (stderr, " where        -i   = use italics in lieu of underline\n");
  1311. X    fprintf (stderr, "              -f   = document has form feeds, ignore line count\n");
  1312. X    fprintf (stderr, "              -l n = make n line nroff'ed documents fit\n");
  1313. X    fprintf (stderr, "              -r n = number of blank lines to remove\n");
  1314. X    fprintf (stderr, "             file = input files (or stdin)\n");
  1315. X    exit (0);    
  1316. X}
  1317. END_OF_FILE
  1318. if test 6253 -ne `wc -c <'pnf.c'`; then
  1319.     echo shar: \"'pnf.c'\" unpacked with wrong size!
  1320. fi
  1321. # end of 'pnf.c'
  1322. fi
  1323. if test -f 'selectdef.c' -a "${1}" != "-c" ; then 
  1324.   echo shar: Will not clobber existing file \"'selectdef.c'\"
  1325. else
  1326. echo shar: Extracting \"'selectdef.c'\" \(5950 characters\)
  1327. sed "s/^X//" >'selectdef.c' <<'END_OF_FILE'
  1328. X/* ta=4 */
  1329. X/*    allow user to select printer from various *.def files
  1330. X    and also select defaule page size (letter, a4 etc)
  1331. X    
  1332. X    selected printer is in file        Ppsfprint.cfg
  1333. X    seleted page size is in file    Ppagesize.cfg
  1334. X
  1335. X    This also generates a postscript programme (psizes.ps) that should be
  1336. X    sent to the printer to print out the actual imageable area.
  1337. X*/
  1338. X
  1339. X#include <stdio.h>
  1340. X
  1341. X#define printerdef "Ppsfprint.cfg"
  1342. X
  1343. Xtypedef struct                     /*    measurement in point                    */
  1344. X{    char    paper_name[60];        /*    name of paper size (for command line)    */
  1345. X    char    paper_tray[200];    /*    postscript operator to select this tray    */
  1346. X    int        width;                /*    portrait point width of paper            */
  1347. X    int        height;                /*    portrait point height of paper            */
  1348. X} measure;
  1349. X
  1350. Xchar *psheader = "%!\n\
  1351. X/getsize {\n\
  1352. X    clippath\n\
  1353. X    pathbbox\n\
  1354. X} def\n\
  1355. X/sendsize {\n\
  1356. X    /ury exch def\n\
  1357. X    /urx exch def\n\
  1358. X    /lly exch def\n\
  1359. X    /llx exch def\n\
  1360. X    /str 64 string def\n\
  1361. X    show\n\
  1362. X    (  ) show\n\
  1363. X    llx    ceiling cvi str cvs show\n\
  1364. X    (  ) show\n\
  1365. X    lly    ceiling cvi str cvs show\n\
  1366. X    (  ) show\n\
  1367. X    urx    floor cvi str cvs show\n\
  1368. X    (  ) show\n\
  1369. X    ury    floor cvi str cvs show\n\
  1370. X} def\n\
  1371. X/pg save def\n\
  1372. Xnewpath\n";
  1373. X
  1374. Xchar *psfont = "/Courier findfont 12 scalefont setfont\n";
  1375. X
  1376. Xchar *pstail = "showpage \n\
  1377. Xpg restore\n\004";
  1378. X
  1379. Xchar    printername[100];
  1380. Xint        defaultsize;
  1381. X
  1382. Xmain (argc, argv)
  1383. Xint        argc;
  1384. Xchar    *argv[];
  1385. X{    int        i,j;
  1386. X    int        many, n, pnumber;
  1387. X    char    printers[100];
  1388. X    FILE    *fp, *fpdef;
  1389. X
  1390. X    if (argc < 2)
  1391. X    {    fprintf (stderr, "Cannot find printer definition files (*.def)...\n");
  1392. X        exit (1);
  1393. X    }
  1394. X    
  1395. Xrefresh:
  1396. X    puts ("\n\n                         SELECT PRINTER TYPE\n");
  1397. X    many = 0;
  1398. X    for (i = 1;  i < argc;  i++)
  1399. X    {    if ((fp = fopen (argv[i], "r")) == NULL)
  1400. X            exit (1);
  1401. X        fgets (printers, 99, fp);
  1402. X        trim (printers);
  1403. X        n = strlen (printers);
  1404. X        if (n < 35)
  1405. X            n = 35;
  1406. X        many += n;    
  1407. X        if (many > 70)
  1408. X        {    many = n;
  1409. X            printf ("\n");
  1410. X        }
  1411. X        printf ("%2d: %-35s", i, printers);
  1412. X        fclose (fp);
  1413. X    }
  1414. X    printf ("\n");
  1415. X    do
  1416. X    {    printf ("==> Select printer by number (q = quit, r = refresh display): ");
  1417. X        gets (printers);
  1418. X        if (toupper (*printers) == 'Q')
  1419. X            exit (44);
  1420. X        if (toupper (*printers) == 'R')
  1421. X            goto refresh;
  1422. X        pnumber = atoi (printers);
  1423. X        if (pnumber < 1  ||  pnumber > argc)
  1424. X            puts ("... Invalid printer number");
  1425. X        else
  1426. X            break;
  1427. X    } while (1);
  1428. X    if (access (argv[pnumber], 4) == 0)
  1429. X    {
  1430. X        if ((fpdef = fopen (printerdef, "w")) != NULL)
  1431. X        {    fprintf (fpdef, "%s", argv[pnumber]);
  1432. X            fclose (fpdef);
  1433. X            getsize (argv[pnumber]);
  1434. X            genpost (argv[pnumber]);
  1435. X        }
  1436. X        else
  1437. X        {    fprintf (stderr, "Cannot create printer definition file: %s\n", printerdef);
  1438. X            exit (1);
  1439. X        }
  1440. X        fclose (fp);
  1441. X    }
  1442. X    else
  1443. X    {    fprintf (stderr, "Cannot find printer definition file: %s\n", argv[pnumber]);
  1444. X        exit (1);
  1445. X    }
  1446. X    exit (0);
  1447. X}
  1448. Xgetsize (fn)
  1449. Xchar    *fn;
  1450. X{    char    ptypes[40][100];
  1451. X    char    line[100];
  1452. X    int        ntypes, i, ncol, pnumber;
  1453. X    FILE    *fpdef;
  1454. X        
  1455. X    if ((fpdef = fopen (fn, "r")) != NULL)
  1456. X    {    fgets (printername, 99, fpdef);
  1457. X        trim (printername);
  1458. X        ntypes = 1;
  1459. X        for ( ; ; )
  1460. X        {    fgets (line, 99, fpdef);
  1461. X            if (*line == '*')
  1462. X                break;
  1463. X            trim (line);
  1464. X            strcpy (ptypes[ntypes], line);
  1465. X            fgets (line, 99, fpdef);
  1466. X            fgets (line, 99, fpdef);
  1467. X            ntypes++;
  1468. X        }
  1469. X        fclose (fpdef);
  1470. X
  1471. Xref:
  1472. X        printf ("\nPrinter is: %s\n\nSelect default page size:\n", printername);
  1473. X        for (i = 1;  i < ntypes;  i++)
  1474. X        {    printf ("%2d: %s\n", i, ptypes[i]);
  1475. X        }
  1476. X        do
  1477. X        {    printf ("==> Select page size by number (q = quit, r = refresh display): ");
  1478. X            gets (line);
  1479. X            if (toupper (*line) == 'Q')
  1480. X                exit (44);
  1481. X            if (toupper (*line) == 'R')
  1482. X                goto ref;
  1483. X            pnumber = atoi (line);
  1484. X            if (pnumber < 1  ||  pnumber > ntypes)
  1485. X                puts ("... Invalid page size number");
  1486. X            else
  1487. X                break;
  1488. X        } while (1);
  1489. X        fclose (fpdef);
  1490. X        ptypes[ntypes][0] = '\0';
  1491. X        if ((pnumber > 0  &&  pnumber < ntypes)
  1492. X            && (fopen ("Ppagesize.cfg", "w")) != NULL)
  1493. X        {
  1494. X            fprintf (fpdef, "%s", ptypes[pnumber]);
  1495. X            fclose (fpdef);
  1496. X            defaultsize = pnumber - 1;
  1497. X        }
  1498. X    }
  1499. X    else
  1500. X    {    fprintf (stderr, "Cannot find printer definition file: %s\n", printerdef);
  1501. X        exit (1);
  1502. X    }
  1503. X    exit (0);
  1504. X}
  1505. X
  1506. Xgenpost (f)
  1507. Xchar    *f;
  1508. X{
  1509. X    FILE *pdef, *psfile;
  1510. X    char    line[500];
  1511. X    measure    page_types[40];
  1512. X    int        i, j;
  1513. X    int        x, y;
  1514. X    
  1515. X    if ((pdef = fopen (f, "r")) != NULL)
  1516. X    {
  1517. X        fgets (line, 100, pdef);
  1518. X        for (i = 0;  i < 28;  i++)
  1519. X        {    if (fgets (page_types[i].paper_name, 59, pdef) == NULL)
  1520. X                break;
  1521. X            trim (page_types[i].paper_name);
  1522. X            if (page_types[i].paper_name[0] ==  '*')
  1523. X                break;
  1524. X            if (fgets (page_types[i].paper_tray, 199, pdef) == NULL)
  1525. X                bad_file();
  1526. X            trim (page_types[i].paper_tray);
  1527. X            if (fgets (line, 100, pdef) == NULL)
  1528. X                bad_file();
  1529. X            trim (line);
  1530. X            sscanf (line, "%d%d",
  1531. X                &page_types[i].width,
  1532. X                &page_types[i].height);
  1533. X
  1534. X        }
  1535. X        page_types[i].paper_name[0] = '\0';
  1536. X        fclose (pdef);
  1537. X        if ((psfile = fopen ("psizes.ps", "w")) != NULL)
  1538. X        {    fprintf (psfile, "%s", psheader);
  1539. X            for (j = i-1;  j >= 0;  j--)
  1540. X            {    lcase (line, page_types[j].paper_name);
  1541. X                fprintf (psfile, "%s\n(%s: %d %d) getsize\n",
  1542. X                            line,
  1543. X                            page_types[j].paper_name,
  1544. X                            page_types[j].width, 
  1545. X                            page_types[j].height);
  1546. X            }
  1547. X            fprintf (psfile, "%s\n", page_types[defaultsize].paper_tray);
  1548. X            fprintf (psfile, "%s", psfont);
  1549. X            x = 50;
  1550. X            y = 600;
  1551. X            fprintf (psfile, "%d %d moveto\n", x, y);
  1552. X            fprintf (psfile, "(Imageable area) show\n");
  1553. X            y -= 15;
  1554. X            fprintf (psfile, "%d %d moveto\n", x, y);
  1555. X            fprintf (psfile, "(");
  1556. X            send (printername, psfile);
  1557. X            fprintf (psfile, ") show\n");
  1558. X            y -= 20;
  1559. X            for (j = i-1;  j >= 0;  j--)
  1560. X            {
  1561. X                fprintf (psfile, "%d %d moveto\nsendsize\n", x, y);
  1562. X                y -= 15;
  1563. X            }
  1564. X            fprintf (psfile, "%s", pstail);
  1565. X        }
  1566. X    }
  1567. X}
  1568. X
  1569. Xtrim (s)
  1570. Xchar    *s;
  1571. X{
  1572. X    while (*s)
  1573. X    {    if (*s < ' ')
  1574. X        {    *s = 0;
  1575. X            break;
  1576. X        }
  1577. X        s++;
  1578. X    }
  1579. X}
  1580. X
  1581. Xbad_file()
  1582. X{
  1583. X    fprintf (stderr, "Bad %s file\n", PDEF);
  1584. X    exit (1);
  1585. X}
  1586. X
  1587. Xlcase (a, b)
  1588. Xchar    *a, *b;
  1589. X{
  1590. X    while (*b)
  1591. X    {    *a++ = tolower (*b);
  1592. X        b++;
  1593. X    }
  1594. X    *a = '\0';
  1595. X}
  1596. X
  1597. Xsend (s, fp)
  1598. Xchar    *s;
  1599. XFILE    *fp;
  1600. X{
  1601. X    char    *strchr();
  1602. X    
  1603. X    while (*s)
  1604. X    {
  1605. X        if (strchr ("\r\b\\()", *s) != NULL)
  1606. X            fputc ('\\', fp);
  1607. X        fputc (*s, fp);
  1608. X        s++;
  1609. X    }
  1610. X}
  1611. END_OF_FILE
  1612. if test 5950 -ne `wc -c <'selectdef.c'`; then
  1613.     echo shar: \"'selectdef.c'\" unpacked with wrong size!
  1614. fi
  1615. # end of 'selectdef.c'
  1616. fi
  1617. echo shar: End of archive 3 \(of 6\).
  1618. cp /dev/null ark3isdone
  1619. MISSING=""
  1620. for I in 1 2 3 4 5 6 ; do
  1621.     if test ! -f ark${I}isdone ; then
  1622.     MISSING="${MISSING} ${I}"
  1623.     fi
  1624. done
  1625. if test "${MISSING}" = "" ; then
  1626.     echo You have unpacked all 6 archives.
  1627.     rm -f ark[1-9]isdone
  1628. else
  1629.     echo You still need to unpack the following archives:
  1630.     echo "        " ${MISSING}
  1631. fi
  1632. ##  End of shell archive.
  1633. exit 0
  1634.  
  1635.